翻訳と辞書
Words near each other
・ BlogPulse
・ BlogScope
・ BlogShares
・ Blogshop
・ Blogswara
・ BlogTalkRadio
・ Blockland
・ Blockleiter
・ Blockley
・ Blockley Almshouse
・ Blockley Township, Pennsylvania
・ Blockly
・ Blockout
・ BlockParty (game portal)
・ Blockquote element
Blocks (C language extension)
・ Blocks of Five
・ Blocks Recording Club
・ Blocks That Matter
・ Blocks to Robots
・ Blocks world
・ Blocksburg, California
・ Blockship
・ Blockshopper
・ Blocksworld
・ Blockton, Iowa
・ Blocktrix
・ Blockula
・ Blockupy movement
・ Blockville, New York


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Blocks (C language extension) : ウィキペディア英語版
Blocks (C language extension)

Blocks are a nonstandard extension added by Apple Inc. to their implementations of the C, C++, and Objective-C programming languages that uses a lambda expression-like syntax to create closures within these languages. Blocks are supported for programs developed for Mac OS X 10.6+ and iOS 4.0+,〔(【引用サイトリンク】title=Blocks Programming Topics )〕 although third-party runtimes allow use on Mac OS X 10.5 and iOS 2.2+.〔https://code.google.com/p/plblocks/〕
Apple designed blocks with the explicit goal of making it easier to write programs for the Grand Central Dispatch threading architecture,〔(Apple Technical Brief on Grand Central Dispatch ), retrieved on June 9, 2009.〕〔(Mac OS X 10.6 Snow Leopard: the Ars Technica review: Blocks )〕 although it is independent of that architecture and can be used in much the same way as closures in other languages. Apple has implemented blocks both in their own branch of the GNU Compiler Collection〔https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html〕 and in the Clang LLVM compiler front end. Language runtime library support for blocks is also available as part of the LLVM project. The Khronos group uses blocks syntax to enqueue kernels from within kernels as of version 2.0 of OpenCL.〔http://www.khronos.org/registry/cl/specs/opencl-2.0-openclc.pdf#page=173〕
Like function definitions, blocks can take arguments, and declare their own variables internally. Unlike ordinary C function definitions, their value can capture state from their surrounding context. A block definition produces an opaque value which contains both a reference to the code within the block and a snapshot of the current state of local stack variables at the time of its definition. The block may be later invoked in the same manner as a function pointer. The block may be assigned to variables, passed to functions, and otherwise treated like a normal function pointer, although the application programmer (or the API) must mark the block with a special operator (Block_copy) if it's to be used outside the scope in which it was defined.
Given a block value, the code within the block can be executed at any later time by calling it, using the same syntax that would be used for calling a function.
==Examples==
A simple example capturing mutable state in the surrounding scope is an integer range iterator:〔:


#include
#include
typedef int (^IntBlock)();
IntBlock MakeCounter(int start, int increment)
int main(void)
/
* Output:

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Blocks (C language extension)」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.